﻿@using MvcControls
@using MvcControls.Controls.Button
@using MvcControls.Controls.Parameters
@using SDM.Domain.Models
@using ViewTexts = SDM.Main.Areas.App.Views.Purchase.Texts;
@using ModelTexts = SDM.Domain.Models.PurchaseTransactionModel.Texts;
@inherits WebViewPage<ICollection<PurchaseTransactionModel>>, ILocalizable<ViewTexts>, ILocalizable<ModelTexts>
@{
    ViewBag.Title = this.Localize<ViewTexts>(t => t.PurchasesManagement);
}
@(Html.Custom()
.Grid(t => t)
.AddPropertyColumn(this.Localize<ModelTexts>(t => t.Time), t => t.Time)
.AddPropertyColumn(this.Localize<ModelTexts>(t => t.Supplier), t => t.Supplier)
.AddDynamicColumn(null, null, t => Html.Custom()
    .Button()
    .Settings(s =>
                  {
                      s.Text = this.Localize<ViewTexts>(t2 => t2.Shared.Edit);
                      s.Action = new ActionParameter("EditTransaction",
                                                     routeValues: new
                                                                      {
                                                                          id = t.ID
                                                                      });
                  })
    +
    Html.Custom()
        .Button()
        .Settings(s =>
        {
            s.Text = this.Localize<ViewTexts>(t2 => t2.Shared.Delete);
            s.ConfirmationText = string.Format(this.Localize<ViewTexts>(t2 => t2.Shared.AreYouSure));
            s.Action = new ActionParameter("DeleteTransaction", routeValues: new { id = t.ID });
            s.Type = ButtonControlInfo.ButtonType.Post;
        })
)
.AddControlToPanel(Html.Custom().Button().Settings(s =>
                                               {
                                                   s.Text = this.Localize<ViewTexts>(t => t.Shared.Add);
                                                   s.Action = new ActionParameter("AddTransaction");
                                               })))